<!--
 * @Author: 胡海
 * @Date: 2020-11-17 21:16:04
 * @LastEditors: 胡海
 * @LastEditTime: 2020-11-17 22:39:02
 * @Description: 
-->
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>扩展运算符和数组的方法</title>
</head>
<body>
    <script>
        /*var o = {a:1}
        var o1 = {b:2}
        var o2 = {c:3}
        Object.assign(o,o1,o2)
        console.log(o);
         
         function fn(option){
              let default s = {
                  a:'默认1',
                  b:'默认2',
                  c:'默认3',
              }
              Object.assign(defaults,OPtion);
              console.log(defaults);
         }
         fn({
             a:1,
             b:2
         })*/
         /*var arr = [1,2,3];
         var arr3 = [4,5,6]
         var arr2 = [...arr,...arr3];
        
         console.log(arr2);

         var obj = {a:1};
         var obj2 = {b:2};
         var o = {...obj,...obj2};
         console.log(o);*/
         /*
            arr.map()
        */
        /*var arr = [1,2,3];
        arr.forEach(function (item,index){
            console.log(item,index);
        })
        var newArr = arr.map(function (item,index){
            console.log(item,index);
            return item * 2;
        })
        //console.log(newArr === arr);
        //与原数组对比返回的数与原来相同就不是新数组，不相同就是，对象是不相同的
         console.log(newArr);*/
         var arr = [1,2,3,4,5,6,7,8,9];
         var item = arr.find(function(item,index){
             return item < 3
         })
         console.log(item);
         //find只能找符合条件的第一个
    </script>
</body>
</html>